package com.wuchao.util;

import com.google.protobuf.Internal;
import javafx.scene.input.DataFormat;
import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author wuchao66
 * @Date 2022/7/8 11:23
 * @Version 1.0
 */
public class StringDateConverter implements Converter<String, Date> {
    private String format;
    public StringDateConverter(String format){
        this.format=format;
    }
    @Override
    public Date convert(String s) {
        Date date=null;
        try {
            date =  new SimpleDateFormat(format).parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return date;
    }
}
